<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/8
 * Time: 14:24
 */

namespace App\Http\Controllers\WeChat;
use EasyWeChat\Factory;
use App\Http\Controllers\Admin\WeChatController;
use Illuminate\Http\Request;

class OauthCallbackController extends EasyWeChatController
{


    public function index(Request $request)
    {

        // 获取 OAuth 授权结果用户信息
        $user = $this->oauth->user();
        session(['wechat_user' => $user->toArray()]);
        $targetUrl = empty(session('target_url')) ? '/' : session('target_url');
        header('location:'. $targetUrl); // 跳转到 user/profile
    }
}